<?php

namespace App\Api\Controllers;

use App\Api\Dao\WithdrawalDao;
use App\Api\Logic\WithdrawalLogic;
use App\Exceptions\ValidationException;
use Illuminate\Http\Request;

/**
 * 用户提现
 */
class WithdrawalController extends BaseController
{
    /**
     * 申请提现
     * @return \Illuminate\Http\JsonResponse
     * @throws ValidationException
     */
    public function applyWithdrawal(Request $request,WithdrawalLogic $withdrawalLogic,WithdrawalDao $withdrawalDao){
        $data = array_merge(['u_id'=>$request->u_id],$request->all());
        $withdrawalLogic->applyWithdrawal($data);
        $result = $withdrawalDao->applyWithdrawal($data);
        return $this->success($result);
    }

    /**
     * 获取用户的申请提现记录
     * @return \Illuminate\Http\JsonResponse
     * @throws ValidationException
     */
    public function getWithdrawalList(Request $request,WithdrawalLogic $withdrawalLogic,WithdrawalDao $withdrawalDao){
        $data = array_merge(['u_id'=>$request->u_id],$request->all());
        $withdrawalLogic->getWithdrawalList($data);
        $result = $withdrawalDao->getWithdrawalList($data);
        return $this->success($result);
    }
}
